package org.erp.product.infrastructure.enums;

import lombok.Getter;

/**
 * 调拨类型枚举
 *
 * @author libin
 * @version 1.0
 * @description: 调拨类型枚举
 * @date 2025/11/14 13:27
 **/
@Getter
public enum TransferTypeEnum {
    DICKER_TRANSFER(0, "溢价调拨"),
    REPAIR_TRANSFER(1, "维修调拨"),
    INSPECTION_TRANSFER(2, "质检调拨"),
    SELL_TRANSFER(3, "销售调拨");

    private final Integer code;
    private final String message;

    TransferTypeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Integer getCodeByMessage(String message) {
        for (TransferTypeEnum item : TransferTypeEnum.values()) {
            if (item.getMessage().equals(message)) {
                return item.getCode();
            }
        }
        return null;
    }

    public static String getMessageByCode(Integer code) {
        for (TransferTypeEnum item : TransferTypeEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getMessage();
            }
        }
        return null;
    }

    public static TransferTypeEnum getByCode(Integer code) {
        for (TransferTypeEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    public static TransferTypeEnum getByMessage(String message) {
        for (TransferTypeEnum value : values()) {
            if (value.getMessage().equals(message)) {
                return value;
            }
        }
        return null;
    }
}
